package com.link.base.base.performance.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.link.core.basic.annotations.JsonParam;
import com.link.core.basic.service.KeyGenerateService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.link.base.base.performance.model.Performance;
import com.link.base.base.performance.service.PerformanceService;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;


/**
 * 绩效考核
 *
 * @author 王昊
 * @date 2020-08-26 17:46:09
 */
@Controller
@RequestMapping("/link/performance")
public class PerformanceController extends BasicController<Performance> {

    @Resource
    private KeyGenerateService keyGenerateService;

    @Resource
    private PerformanceService performanceService;

    @Override
    public BasicService<Performance> getBasicService() throws Exception {
        return performanceService;
    }

    /**
     * 绩效自评提交审批
     */
    @RequestMapping(value = "/performSubmit",method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> performSubmit(@JsonParam Performance entity, HttpSession session, HttpServletRequest request) {
        Map<String, Object> result = new HashMap<String, Object>(4);
        try {
            performanceService.performSubmit(entity);
            result.put("newRow",entity);
            result.put("success", true);
        } catch (Exception e) {
            result.put("success", false);
            result.put("result", e.getMessage());
        }
        return result;
    }

}